package com.bhawana.examples.servlets;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bhawana.examples.User;



/**
 * Servlet implementation class HelloServlet
 */
public class HelloServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HelloServlet() {
        super();
        
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("welcome toooo servlet ");
		PrintWriter pw = response.getWriter();
	 String name =request.getParameter("name");
	 String email =request.getParameter("email");
	 String id =request.getParameter("id");
	 String password =request.getParameter("password");
	 
	 pw.print("hello from server");
	 pw.print("\n");
		pw.print("\n" +"fname :" +name);
		pw.print("\n"+ "email :" +email);
		pw.print("\n"+" id :" +id);
		pw.print("\n"+" password :" +password);
		
		User u1 = new User(name,id,email,password);
		if(u1.saveUser())
			 pw.print("User1 saved successfully");
		
	
		u1.update();
		if(u1.update())
			 pw.print("User1 updated successfully");
		
		u1.delete();
		if(u1.delete())
			 pw.print("User1 deleted successfully");
		
			
		 
		 
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
